home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / ncurses-5.3 / ncurses / tinfo / lib_acs.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-27  |  6.2 KB  |  178 lines

  1. /****************************************************************************
  2.  * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc.              *
  3.  *                                                                          *
  4.  * Permission is hereby granted, free of charge, to any person obtaining a  *
  5.  * copy of this software and associated documentation files (the            *
  6.  * "Software"), to deal in the Software without restriction, including      *
  7.  * without limitation the rights to use, copy, modify, merge, publish,      *
  8.  * distribute, distribute with modifications, sublicense, and/or sell       *
  9.  * copies of the Software, and to permit persons to whom the Software is    *
  10.  * furnished to do so, subject to the following conditions:                 *
  11.  *                                                                          *
  12.  * The above copyright notice and this permission notice shall be included  *
  13.  * in all copies or substantial portions of the Software.                   *
  14.  *                                                                          *
  15.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
  16.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
  17.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
  18.  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
  19.  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
  20.  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
  21.  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
  22.  *                                                                          *
  23.  * Except as contained in this notice, the name(s) of the above copyright   *
  24.  * holders shall not be used in advertising or otherwise to promote the     *
  25.  * sale, use or other dealings in this Software without prior written       *
  26.  * authorization.                                                           *
  27.  ****************************************************************************/
  28.  
  29. /****************************************************************************
  30.  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  31.  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
  32.  ****************************************************************************/
  33.  
  34. #include <curses.priv.h>
  35. #include <term.h>        /* ena_acs, acs_chars */
  36.  
  37. MODULE_ID("$Id: lib_acs.c,v 1.22 2002/09/01 19:26:57 tom Exp $")
  38.  
  39. #if BROKEN_LINKER
  40. NCURSES_EXPORT_VAR(chtype *)
  41. _nc_acs_map(void)
  42. {
  43.     static chtype *the_map = 0;
  44.     if (the_map == 0)
  45.     the_map = typeCalloc(chtype, ACS_LEN);
  46.     return the_map;
  47. }
  48. #else
  49. NCURSES_EXPORT_VAR(chtype) acs_map[ACS_LEN] =
  50. {
  51.     0
  52. };
  53. #endif
  54.  
  55. NCURSES_EXPORT(void)
  56. _nc_init_acs(void)
  57. {
  58.     T(("initializing ACS map"));
  59. #if !BROKEN_LINKER
  60.     memset(acs_map, 0, sizeof(acs_map));
  61. #endif
  62.  
  63.     /*
  64.      * Initializations for a UNIX-like multi-terminal environment.  Use
  65.      * ASCII chars and count on the terminfo description to do better.
  66.      */
  67.     ACS_ULCORNER = '+';        /* should be upper left corner */
  68.     ACS_LLCORNER = '+';        /* should be lower left corner */
  69.     ACS_URCORNER = '+';        /* should be upper right corner */
  70.     ACS_LRCORNER = '+';        /* should be lower right corner */
  71.     ACS_RTEE = '+';        /* should be tee pointing left */
  72.     ACS_LTEE = '+';        /* should be tee pointing right */
  73.     ACS_BTEE = '+';        /* should be tee pointing up */
  74.     ACS_TTEE = '+';        /* should be tee pointing down */
  75.     ACS_HLINE = '-';        /* should be horizontal line */
  76.     ACS_VLINE = '|';        /* should be vertical line */
  77.     ACS_PLUS = '+';        /* should be large plus or crossover */
  78.     ACS_S1 = '~';        /* should be scan line 1 */
  79.     ACS_S9 = '_';        /* should be scan line 9 */
  80.     ACS_DIAMOND = '+';        /* should be diamond */
  81.     ACS_CKBOARD = ':';        /* should be checker board (stipple) */
  82.     ACS_DEGREE = '\'';        /* should be degree symbol */
  83.     ACS_PLMINUS = '#';        /* should be plus/minus */
  84.     ACS_BULLET = 'o';        /* should be bullet */
  85.     ACS_LARROW = '<';        /* should be arrow pointing left */
  86.     ACS_RARROW = '>';        /* should be arrow pointing right */
  87.     ACS_DARROW = 'v';        /* should be arrow pointing down */
  88.     ACS_UARROW = '^';        /* should be arrow pointing up */
  89.     ACS_BOARD = '#';        /* should be board of squares */
  90.     ACS_LANTERN = '#';        /* should be lantern symbol */
  91.     ACS_BLOCK = '#';        /* should be solid square block */
  92.     /* these defaults were invented for ncurses */
  93.     ACS_S3 = '-';        /* should be scan line 3 */
  94.     ACS_S7 = '-';        /* should be scan line 7 */
  95.     ACS_LEQUAL = '<';        /* should be less-than-or-equal-to */
  96.     ACS_GEQUAL = '>';        /* should be greater-than-or-equal-to */
  97.     ACS_PI = '*';        /* should be greek pi */
  98.     ACS_NEQUAL = '!';        /* should be not-equal */
  99.     ACS_STERLING = 'f';        /* should be pound-sterling symbol */
  100.  
  101.     if (ena_acs != NULL) {
  102.     TPUTS_TRACE("ena_acs");
  103.     putp(ena_acs);
  104.     }
  105. #define ALTCHAR(c)    ((chtype)(((unsigned char)(c)) | A_ALTCHARSET))
  106.  
  107.     if (acs_chars != NULL) {
  108.     size_t i = 0;
  109.     size_t length = strlen(acs_chars);
  110.  
  111.     while (i < length)
  112.         switch (acs_chars[i]) {
  113.         case 'l':
  114.         case 'm':
  115.         case 'k':
  116.         case 'j':
  117.         case 'u':
  118.         case 't':
  119.         case 'v':
  120.         case 'w':
  121.         case 'q':
  122.         case 'x':
  123.         case 'n':
  124.         case 'o':
  125.         case 's':
  126.         case '`':
  127.         case 'a':
  128.         case 'f':
  129.         case 'g':
  130.         case '~':
  131.         case ',':
  132.         case '+':
  133.         case '.':
  134.         case '-':
  135.         case 'h':
  136.         case 'i':
  137.         case '0':
  138.         case 'p':
  139.         case 'r':
  140.         case 'y':
  141.         case 'z':
  142.         case '{':
  143.         case '|':
  144.         case '}':
  145.         acs_map[(unsigned int) acs_chars[i]] =
  146.             ALTCHAR(acs_chars[i + 1]);
  147.         i++;
  148.         /* FALLTHRU */
  149.         default:
  150.         i++;
  151.         break;
  152.         }
  153.     }
  154. #ifdef TRACE
  155.     /* Show the equivalent mapping, noting if it does not match the
  156.      * given attribute, whether by re-ordering or duplication.
  157.      */
  158.     if (_nc_tracing & TRACE_CALLS) {
  159.     size_t n, m;
  160.     char show[ACS_LEN + 1];
  161.     for (n = 1, m = 0; n < ACS_LEN; n++) {
  162.         if (acs_map[n] != 0) {
  163.         show[m++] = (char) n;
  164.         show[m++] = ChCharOf(acs_map[n]);
  165.         }
  166.     }
  167.     show[m] = 0;
  168.     _tracef("%s acs_chars %s",
  169.         (acs_chars == NULL)
  170.         ? "NULL"
  171.         : (strcmp(acs_chars, show)
  172.            ? "DIFF"
  173.            : "SAME"),
  174.         _nc_visbuf(show));
  175.     }
  176. #endif /* TRACE */
  177. }
  178.